import request from "../request";
//获取角色列表
async function getRoleList() {
  const data = await request({
    url: "roles",
    method: "get",
  });
  return data;
}
//添加角色
async function addRoleList(props: Idata) {
  const data = await request({
    url: `roles`,
    method: "post",
    data: props,
  });
  return data;
}
// 删除角色
async function DeleteRole(id: number) {
  const data = await request({
    url: `roles/${id}`,
    method: "delete",
    data: {
      id,
    },
  });
  return data;
}
//编辑角色
async function EditRole(props: Idata) {
  const data = await request({
    url: `roles/${props.id}`,
    method: "put",
    data: props,
  });
  return data;
}
//获取分配权限的列表
async function getRoleAuth() {
  const data = await request({
    url: `rights/tree`,
    method: "get",
  });
  return data;
}
// 给角色授权
async function addAuth(props: Idata) {
  const data = await request({
    url: `roles/${props.roleId}/rights`,
    method: "post",
    data: props,
  });
  return data;
}
export default {
  getRoleList,
  EditRole,
  addRoleList,
  DeleteRole,
  getRoleAuth,
  addAuth,
};
